//
//  Home.h
//  A One POS
//
//  Created by AonePOS on 24/09/13.
//  Copyright (c) 2013 AonePOS. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "HomeSearchCell.h"
#import "RecallInvoiceCell.h"
#import "FetchonHoldCell.h"
#import "SplitInvoiceCell.h"
#import "HomeCustomerCell.h"
#import "HomeProductListCell.h"
#import "AppDelegate.h"
@interface Home : UIViewController<UITextFieldDelegate,UITableViewDataSource,UITableViewDelegate,UIAlertViewDelegate,NSURLConnectionDataDelegate,UITextViewDelegate,UIWebViewDelegate>

{
    
    UIView *sidemenu,*mainview,*backgroundcolorview;
    UIButton *categorybutton;
    UIToolbar *downtoolBar,*maintoolBar;
    UIImageView *logobackview,*logoimageview;
    int y,p;
    _Bool isLandScope;
     UIButton *helpiconButton,*logouticonButton,*menubutton;
    BOOL menuslected;
    UIButton *backButton3,*backButton2,*backButton;
    UINavigationBar *navBar;
    
    UIView *HomebackView;
    UIButton *ProductscanBtn,*Quantitybtn,*QtyGobtn,*DeleteBtn,*PriceChangeBtn,*QuantyChangeBtn,*DiscountBtn,*PayBtn;
    UITextField *ProductscanField,*QantyField;
    UIButton *VoidInVoiceBtn,*retraiveOnHoldBtn,*CashBtn,*CheckBtn,*CreditBtn,*SearchBtn;
    UITableView *ProductslistTable;
    UIView *tablestripview;
    UILabel *snolbl,*itemlbl,*iteminfolbl,*qntylbl,*pricelbl;
    
    UIView *custBackview;
    UIButton *AddBtn,*FindBtn,*CustomerBtn,*CustomerinflBtn;
    
    
    UIView *SubtotalView,*blackstripview,*GrandtotalView;
   
    UILabel *Subtlbl,*SubTDisplaylbl,*Taxlbl,*taxDlbl,*GrandTlbl,*GTotalDlbl;
   
    UITableView *DepartmentsTable;
    NSMutableArray *departmentsArray,*ItemsArray,*ItemChecksArray;
    
    UIButton *ItemBtn;
    UIScrollView *itemsView;
    
    
    NSMutableArray *ItemNosArray,*ItemNamesArray,*QntysArray,*pricesArray,*productnosArray,*SnosArray,*TaxesArray;
    
    UIButton *DeleteItemBtn;
    UITextView  *namelbl, *taxlbl,*stock,*Deslbl,*Vendorlbl;
    UIAlertView *ItemsDeleteAlert;
   
//Search Data View
    
    UIView *SearchViewpopup;
    UIScrollView *SearchView;
    UITableView *SearchlistTable;
    UILabel *Catlbl,*Deptlbl;
    UIButton *CatBtn,*DeptBtn,*Gobtn,*CancelItemBtn;
    UITextField *SearchField;
    
//product category view
    UIView *Pcategorypopup;
    UITableView *PCategorysTable;
//Product department view
    UIView *Pdeaprtmentpopup;
    UITableView *PdepartmentsTable;
    UITableView *ItemsDataTable;
    
    NSMutableArray *SearchDataArray;
    NSMutableArray *pastDataArray;
    NSMutableArray *DepartmentNamesArray,*categorynamesArray;
    
    NSMutableArray *ItemNumbersArray,*ItemnameArray,*productDesArray,*priceyouchargeArray,*InstockArray,*VendorpartNosArray;
    
    UITextView  *itemnolbl,*Itemnamelbl,*Ppricelbl,*Instock,*Pdeslbl,*vendornolbl,*Snolbl;
  
    
    double SubtotalValue;
    double TaxValue,Grandvalue,TotalAvegCost;
    
    
    NSString *SubTotalstr,*TaxValueStr,*GrandTotalstr,*TotalAvgStr;
    
     int quantity;
    double Pricevalue;
    
     int itemcount;
    
    int indexNO;
    BOOL itemselected;
    
// Change Quantity View
    UIView *QuantityPopupView,*Quantityview;
    UILabel *QTextlbl;
    UIButton *SaveQtyBtn,*CancelQtyBtn;
    UITextField *ChangeQuantityField;

// Change price View
    UIView *PricePopupView,*Priceview;
    UILabel *PriceTextlbl;
    UIButton *SavePriceBtn,*CancelPriceBtn;
    UITextField *ChangePriceField;
// Change Discount View
    UIView *DiscountPopupView,*Discountview;
    UILabel *DiscountTextlbl,*OverAllDislbl;
    UIButton *SaveDiscountBtn,*CancelDiscountBtn;
    UITextField *ChangeDiscountField;
    
    UIButton *DisCheckBtn,*DisDropdownBtn;
    UITableView *DisTableview;
    NSMutableArray *DiscsArray;
    
    
    
//Pay View
    UIView *PaypopupView;
    UIScrollView *PayView;
    
    UILabel *Amountlbl,*GivenAmountlbl,*Paytypelbl,*SelectPrinterlabel,*PrintertextLbl;
    UITextField *AmountField,*GivenAmountField;
    UIButton *CashDropDown,*AmountBtn,*CancelPayBtn,*SavePayBtn,*SelectPrinterBtn;
    UIButton *DeleteGivenAmntBtn;
    UITableView *CashlistTable,*PayPrinterDataTable;
    
    NSArray *paytypesArray;
    UISwitch *PrinterSwitch;
    NSMutableArray *PrinterIpsArray;
    
    NSString *PrinterswitchValue;
    
       NSMutableArray *printcharArray,*FontsArray,*AlignsArray,*languagesArray,*WidthsArray,*HeightsArray,*boldsArray,*UnderlinesArray,*XpossArray,*unitsArray,*spacingsArray,*printernamesArray,*IpAddsArray,*DBPrintertypesArray;
    
    NSString *PayPrinterName,*printChar,*font,*align,*language,*Pwidth,*Pheight,*Bold,*Underline,*xposition,*spacing,*Ipadd,*unit,*Dbprintertype;
    
    
//
    UIAlertView *Changealert;

    NSMutableArray *DiscountsArray,*AvegCostsArray,*ItemDesArray,*ItemVendorArray,*ItemDeptsArray;
    
    NSString *paymentType;
    NSString *HoldStatus;
    
    NSURLConnection *InvoiceItemsConnection,*InvoiceTotalConnection;
    NSMutableData *InvoiceItemData,*InvoiceTotalData;
    
    
   //Printer View
    
    UIView *PrinterpopupView,*PrinterView;
    UILabel *textlbl,*selectprinterlbl;
    UIButton *SelectPrintBtn,*YesPrintBtn,*NoPrintBtn;
    UITableView *PrinterDataTable;
    NSMutableArray *PrintersArray;
    
    UISwitch *Myswitch;
    UILabel *Modelbl;
    NSString *remainingamountstr;
    
    
//Customer View

    UIView *CustomerViewpopup;
    UIScrollView *CustomerView;
    UITableView *CustomerlistTable;
    UIButton *CustomerGobtn,*CustomerCancelBtn;
    UITextField *CustomerSearchField;
    UITableView *CustomerDataTable;
   
    
    NSMutableArray *CustomerPastDataArray,*CustomerDataArray;
    NSMutableArray *CustomerNosArray,*CuFirstnamesArray,*CuLastnamesArray,*ShCompanynamesArray,*ShPhonenumbersArray,*CuSnosArray;
    
    NSString *CustomerNO,*CustomerName,*CusomerCompany,*CustomerPhoneNumber;
    
    
    UILabel *Customernamelbl,*CustomerNolbl;
    
    //NSMutableString *stringToPrint;
    
//Fetch On Hold View
    
    
    UIView *FetchOnHoldBackView,*FetchOnHoldView;

    UITableView *FecthOnHoldlistTable;
    UILabel *Fetchlbl;
    UILabel *PrintatDeptlbl,*Swicthtextlbl;;
    UISwitch *PrintDeptSwitch;
    NSString *HoldID,*invoiceID;
    NSString *DeptSwitchValue;
    
    NSMutableArray *InVoiceIdsArray,*TotalAmountsArray,*StatusArray,*HoldIdsArray,*TimesArray,*CustomersArray,*EmployeesArray;
    
//Product Printer View
    UIView *ProductPrinterPopUp;
    UIScrollView *ProductPrinterView;
    UITableView *ProductPrintertable;
    UIButton *PrinterBtn,*TimeBtn,*SavePrintBtn,*CancelPrintBtn;
    UITextField *ProductTextView;
    UILabel *PrintTextlbl;
    NSMutableArray *DepPrinterDataArray,*DepTimesArray,*QtyitemsArry,*ProductNamesArray;
    
    NSMutableArray *PrinterNamesArray,*MinitsArray;
    
//Printer View
    
    UIView *printerPopup;
    UITableView *PrinterNamesTable,*MinitsTable;
    UIView *MinitsPopup;
    
    NSInteger SelectedPrinter,SelectedTime;
 
    UIButton *EditPrinter,*DeleteinvoiceData;
//Employee Store Ids View
    UIView *StoresPopupView,*StoresView;
    UIButton *SelectStoreBtn,*ProceedStoreBtn;
    
    UITableView *StoresListTable;
    NSMutableArray *StoresArray;
    UILabel *SelectStorelbl;
    
    NSString *StoreID;
    UIAlertView *DeleteInvoiceAlert;
    NSInteger selectededInvoice;
   
    
    UIButton *cellButton;
//Product scan view
    UIView *ProductscanBackView,*ProductScanView;
    UILabel *ScanTextlbl;
    UITextField *ProductScanField;
    
    UIButton *SaveBarCodeBtn,*CancelBarCodeBtn,*ScanItemBtn;
    
    

     BOOL blocking ;

    NSString *PrinterHoldID;
    
    UIButton *PrintLastInvcBtn,*RecallBtn;
  
    
//Search Data View
    
    UIView *RecallViewpopup;
 
    UITableView *RecallListTable;
    
    NSMutableArray *RsonsArray,*paymentTypesArray;
    
    BOOL RecallinvoiceValue;
    
    
    
    UILabel *sationLbl,*Timelbl,*EmpIdlbl;
    UIButton *logoBtn;
    
   // UILabel *titleLabel;
    BOOL ItemboolVlaue;
    
    
    UIButton *SplitInvoiceBtn;
    
 //Split Invoice View
    UIView *SplitInvoicepopUp,*SplitInvoiceView;
    UILabel *SplitInvoiceLabel;
    UIButton *SplitInvoiceSaveBtn;
    UITextField *SplitInvoiceTextField;
    
    NSMutableArray *SplitNamesArray,*SplitQytsArray,*SplitPricesArray;
    
    UIView *SplittablePopUpView;
     UIScrollView *SplittableBackView;
    
    UITableView *SplitDataTable;
    
    int numberofSplits;
    
//Divya coding
    
    //checknum Variables
    UITextField * checkNumTxt;
    
    UILabel * checkNumLbl;
    
    UIView * checkPopUp, * checkPopUpPay;
    
    UIButton *checkNumBtn;
    
    NSString * payment_type , * split_amount, * check_no, * account_no, * invoice_id;
    
    double amount,givenamout;
    NSString *SplitInvoiceID;
    
    
    UITableView *SplitInvoiceTable;
    
    NSMutableArray *SplitpaymentsArray,*splitAmoutsArray;
    NSString *PrintSplitInvoiceID,*TotalPaymetType;
    NSString *InvoiceCheckNo;
    
    NSString *RecallInvoiceID;
    
    NSString *InVoiceCustomer;
    
    
    NSString *EmployeeID;
    
    UITextView *PrinttextView;
    
    UIImage *Printimage;
   // UIWebView *webView1;
    CGRect PrintHeightrect;
    
    NSString *SearchPrinterStr;
    NSMutableArray *searchPrinterArray;
    int  result1;
    
    IBOutlet HomeSearchCell *homeSearchCell;
    IBOutlet RecallInvoiceCell *recallInvoiceCell;
    IBOutlet FetchonHoldCell *fetchonHoldCell;
    IBOutlet SplitInvoiceCell *splitInvoiceCell;
    IBOutlet HomeCustomerCell *homeCustomerCell;
    IBOutlet HomeProductListCell *homeProductListCell;
    
    UIView *modifierPopupView,*modifieView;
    UIButton *okmodifier_Button,*cancelmodifier_Button,*modifierItem_Button;;
    NSMutableArray *modifierItemsArray,*selectedModifieritemsArray;
    UIAlertView *billprintAlertView;
    BOOL modifierBoolValue;
 
}

-(void)GetTotalAmountMethod;
-(void)SaveInvoiceDataMethod;
-(void)PrinterViewMethod;
-(void)UpdateInVoiceDataMethod;
//-(void)AddSplitViewTablesMethod;

+(UIImage *) imageFromWebView:(UIWebView *)view;
@property(nonatomic,strong)  NSString  *amountString;
- (IBAction)fetch_editButtonClicked:(id)sender;
- (IBAction)fetch_deleteButtonClicked:(id)sender;
- (IBAction)productData_deleteButtonClicked:(id)sender;
-(void)releaseViews;
-(void)saveapproveCardDataMethod:(NSString *)paymentresult;

@end
